package com.app114.app.android.rk.adapter;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.app114.app.android.rk.bean.WebSiteItem;

public class WebsAdapter extends ArrayAdapter<WebSiteItem> {

	private List<WebSiteItem> webs = new ArrayList<WebSiteItem>();
	private Context mContext;

	public WebsAdapter(Context context, List<WebSiteItem> webs) {
		super(context, 0, webs);
		this.webs = webs;
		mContext = context;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Holder holder;
		if (convertView == null) {
			convertView = LayoutInflater.from(mContext).inflate(android.R.layout.simple_list_item_1, null);
			holder = new Holder();
			holder.title = (TextView) convertView.findViewById(android.R.id.text1);
			convertView.setTag(holder);
		} else {
			holder = (Holder) convertView.getTag();
		}

		WebSiteItem webItem = getItem(position);

		// Load the image and set it on the ImageView
		String title = webItem.getName();
		holder.title.setText(title);
		return convertView;
	}

	private static class Holder {
		TextView title;
	}
}
